package com.qdlc.p2p.dal.dao.impl;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import com.qdlc.p2p.dal.common.dao.jpa.BaseDaoImpl;
import com.qdlc.p2p.dal.dao.TppMemberAgentDao;
import com.qdlc.p2p.dal.dto.MemberAgent;

/**
 * Created by lenovo on 2015/11/11.
 */

@Repository("tppMemberAgentDao")
public class TppMemberAgentDaoImp extends BaseDaoImpl<MemberAgent> implements TppMemberAgentDao{
    @SuppressWarnings("unchecked")
    @Override
    public MemberAgent findMemberAgentByUserId(long userId) {
        String jpql = " from MemberAgent where user_id = ?1";
        Query query = em.createQuery(jpql);
        query.setParameter(1, userId);
        MemberAgent memberAgent = (MemberAgent)query.getSingleResult();

        return memberAgent;
        }

}
